package com.sxt.springcloud.sys;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sxt.springcloud.sys.fallback.UserClientFallbackService;
import com.sxt.sys.common.DataGridView;
import com.sxt.sys.common.ResultObj;
import com.sxt.sys.domain.Role;
import com.sxt.sys.domain.User;
import com.sxt.sys.vo.UserVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Component
@FeignClient(value = "SPRINGCLOUD-PROVIDER-SYS",fallbackFactory = UserClientFallbackService.class)
@RequestMapping("/p/user")
public interface UserClientService {

    @RequestMapping("getOne")
    User getOne(@RequestParam("tokengetPrincipal") String tokengetPrincipal);

    /**
     * 用户全查询
     */
    @RequestMapping("loadAllUser")
    DataGridView loadAllUser(UserVo userVo);



    /**
     * 加载最大的排序码
     * @param
     * @return
     */
    @RequestMapping("loadUserMaxOrderNum")
    Map<String,Object> loadUserMaxOrderNum();


    /**
     * 根据部门ID查询用户
     */
    @RequestMapping("loadUsersByDeptId")
    DataGridView loadUsersByDeptId(@RequestParam("deptid") Integer deptid);


    /**
     * 把用户名转成拼音
     */
    @RequestMapping("changeChineseToPinyin")
    Map<String,Object> changeChineseToPinyin(@RequestParam("username") String username);

    /**
     * 添加用户
     */
    @RequestMapping("addUser")
    ResultObj addUser(@RequestBody UserVo userVo);


    /**
     * 根据用户ID查询一个用户
     */
    @RequestMapping("loadUserById")
    DataGridView loadUserById(@RequestParam("id") Integer id);

    /**
     * 修改用户
     */
    @RequestMapping("updateUser")
    ResultObj updateUser(@RequestBody UserVo userVo);

    /**
     * 删除用户
     */
    @RequestMapping("deleteUser")
    ResultObj deleteUser(@RequestParam("id") Integer id);
    /**
     * 重置用户密码
     */
    @RequestMapping("resetPwd")
    ResultObj resetPwd(@RequestParam("id") Integer id);


    /**
     * 根据用户ID查询角色并选中已拥有的角色
     */
    @RequestMapping("initRoleByUserId")
    DataGridView initRoleByUserId(@RequestParam("id")  Integer id);

    /**
     * 保存用户和角色的关系
     */
    @RequestMapping("saveUserRole")
    ResultObj saveUserRole(@RequestParam("uid") Integer uid,@RequestParam("ids")Integer[] ids);

    /**
     * 用户修改密码-旧密码验证
     */
    @RequestMapping("checkedoldpwd")
    ResultObj checkedoldpwd(@RequestParam("oldpwd") String oldpwd);
    /**
     * 用户修改密码
     */
    @RequestMapping("udpatepwd")
    ResultObj udpatepwd(@RequestParam("newpwd") String newpwd);



}
